﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class Manager<T> : SingletonCSharp<T>, IManager where T : class, new()
{
    private LogicWeight _logicWeight;
    public LogicWeight logicWeight
    {
        get
        {
            return _logicWeight;
        }
    }
    protected MonoBehaviour mainRoot;
    public void SetMono(MonoBehaviour mono,LogicWeight weight)
    {
        mainRoot = mono;
        _logicWeight = weight;
    }

    #region Interface
    public virtual void OnAwake() { }
    public virtual void OnDestroy() { }
    public virtual void OnEnterScene() { }
    public virtual void OnExitScene() { }
    public virtual void OnFocus(bool focus) { }
    public virtual void OnInit() { }
    public virtual void OnPause(bool pause) { }
    public virtual void OnReset() { }
    #endregion

    #region Coroutine
    public UnityEngine.Coroutine StartCoroutine(IEnumerator routine)
    {
        return mainRoot.StartCoroutine(routine);
    }
    public UnityEngine.Coroutine StartCoroutine(string functionName)
    {
        return mainRoot.StartCoroutine(functionName);
    }
    public void StopCoroutine(IEnumerator routine)
    {
        mainRoot.StopCoroutine(routine);
    }
    public void StopCoroutine(string functionName)
    {
        mainRoot.StopCoroutine(functionName);
    }
    public void StopAllCoroutines()
    {
        mainRoot.StopAllCoroutines();
    }
    #endregion
}
